<?php

class wms_finder_stockapp
{

	var $column_edit = '操作';
	var $column_edit_width = "50";

    var $detail_stockapp_delis = "发货单明细";
	public function column_edit($row)
	{
		$finder_id = $_GET['_finder']['finder_id'];

        $stockappMdl = app::get('wms')->model('stockapp');
        $stockapp_datas= $stockappMdl->getList('status', array('id' => $row['id'] ),0,1);
        if($stockapp_datas[0]['status']=='confirmed' ||$stockapp_datas[0]['status']=='approved')
        {
            return '';
        }else
        {
        return '<a href="index.php?app=wms&ctl=admin_stockapp&act=editstockapp&id=' . $row['id'] . '&finder_id='.$finder_id.'" target="_blank">编辑</a>';
        }
	}

    /*
     * 备货通知单明细
     */
    function detail_stockapp_delis($row){
        $render = app::get('wms')->render();
        $sql="SELECT e.delivery_bn,os.order_bn,f.AXCustomer,f.customername,f.name shop_name,deli.status,deli.bnsContent from  sdb_wms_delivery e 
         inner join sdb_ome_shop f on e.shop_id = f.shop_id
         inner JOIN sdb_ome_delivery od on ( e.outer_delivery_bn = od.delivery_bn )
         inner JOIN sdb_ome_delivery_order odo on ( od.delivery_id = odo.delivery_id )
         inner JOIN sdb_ome_orders os on (odo.order_id = os.order_id)
         inner join sdb_wms_stockapp_delis deli on e.delivery_id=deli.delivery_id where deli.stockapp_id=".$row;
        
        $db=kernel::database();
        $basicMaterialInfo=$db->select($sql);   
        foreach ($basicMaterialInfo as $key => $value) 
        {
            $cnts = unserialize($value['bnsContent']);
            $basicMaterialInfo[$key]['bnsContent']=implode(',',$cnts);
        }     
        $render->pagedata['res'] = $basicMaterialInfo;
        return $render->fetch('admin/stockapp/stockapp_delis.html');
    }
}